import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { DeliveryService } from './delivery.service';
import { CreateDeliveryDto, UpdateDeliveryStatusDto } from './delivery.dto';

@ApiTags('投递简历模块')
@ApiBearerAuth()
@Controller('delivery')
export class DeliveryController {
  constructor(private deliveryService: DeliveryService) {}

  @Post('create')
  @ApiOperation({ summary: '投递简历' })
  async createDelivery(@Body() data: CreateDeliveryDto) {
    return await this.deliveryService.create(data);
  }

  @Get('job/list')
  @ApiOperation({ summary: '获取岗位列表' })
  async getJobList(@Query() query: { userId: string }) {
    return await this.deliveryService.findJob(query.userId);
  }

  @Get('status/:id')
  @ApiOperation({ summary: '获取岗位列表' })
  async getDeliveryStatus(@Param('id') id: string) {
    return await this.deliveryService.findStatus(+id);
  }

  @Get('user/list/:id')
  @ApiOperation({ summary: '获取投递用户列表' })
  async getDeliveryUserList(@Param('id') id: string) {
    return await this.deliveryService.findUser(id);
  }

  @Put('update/status')
  @ApiOperation({ summary: '更新投递简历状态' })
  async updateDeliveryStatus(@Body() data: UpdateDeliveryStatusDto) {
    return await this.deliveryService.updateStatus(data);
  }
}
